# Make file for Scintilla on Linux or compatible OS
# Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
# The License.txt file describes the conditions under which this software may be distributed.
# This makefile assumes GCC 3.1 is used and changes will be needed to use other compilers.
# GNU make does not like \r\n line endings so should be saved to CVS in binary form.
# Builds for GTK+ 2 if available else GTK+ 1.
# To force GTK+ 2 build, define GTK2 on the make command line.
# To force GTK+ 1 build, define GTK1 on the make command line.

.SUFFIXES: .cxx .c .o .h .a
CXX = g++
CC = gcc
AR = ar
RANLIB = ranlib
PREFIX = C:/libs
RM = del
-include ../localwin32.mk

ifdef MSYS
RM = rm -f
endif

COMPLIB=scintilla.a

GTK_INCLUDES= \
	-I$(PREFIX)/include/gtk-2.0 \
	-I$(PREFIX)/lib/gtk-2.0/include \
	-I$(PREFIX)/include/atk-1.0 \
	-I$(PREFIX)/include/cairo \
	-I$(PREFIX)/include/gdk-pixbuf-2.0 \
	-I$(PREFIX)/include/pango-1.0 \
	-I$(PREFIX)/include/glib-2.0 \
	-I$(PREFIX)/lib/glib-2.0/include \
	-I$(PREFIX)/include \
	-I$(PREFIX)/include/gettext


vpath %.h gtk lexers lexlib src include
vpath %.cxx gtk lexers lexlib src
vpath %.c gtk

INCLUDEDIRS=-I include -I src -I lexlib -I . $(GTK_INCLUDES)
CXXBASEFLAGS=-Wall -Wno-missing-braces -Wno-char-subscripts -DGTK -DSCI_LEXER $(INCLUDEDIRS) -mms-bitfields

ifdef THREADS
THREADFLAGS=
else
THREADFLAGS=-DG_THREADS_IMPL_NONE
endif

ifdef DEBUG
CXXFLAGS=-DDEBUG -g -O0 $(CXXBASEFLAGS) $(THREADFLAGS)
else
CXXFLAGS=-DNDEBUG -Os $(CXXBASEFLAGS) $(THREADFLAGS)
endif

CONFIGFLAGS=$(GTK_INCLUDES)
MARSHALLER=scintilla-marshal.o

.cxx.o:
	$(CXX) $(CXXFLAGS) -c $<
.c.o:
	$(CC) $(CXXFLAGS) -c $<

LEXOBJS=\
LexAda.o \
LexAsm.o \
LexBash.o \
LexCOBOL.o \
LexCSS.o \
LexCPP.o \
LexHTML.o \
LexOthers.o \
LexPascal.o \
LexPerl.o \
LexPython.o \
LexSQL.o \
LexCaml.o \
LexTCL.o \
LexTxt2tags.o \
LexRuby.o \
LexErlang.o \
LexForth.o \
LexFortran.o \
LexVHDL.o \
LexVerilog.o \
LexMarkdown.o \
LexMatlab.o \
LexD.o \
LexLisp.o \
LexLua.o \
LexHaskell.o \
LexBasic.o \
LexR.o \
LexYAML.o \
LexCmake.o \
LexNsis.o

all: $(COMPLIB)

clean:
	-$(RM) deps.mak *.o $(COMPLIB)

SRCOBJS=\
	PlatGTK.o \
	ScintillaGTK.o \
	Accessor.o \
	CharacterSet.o \
	LexerBase.o \
	LexerModule.o \
	LexerNoExceptions.o \
	LexerSimple.o \
	PropSetSimple.o \
	StyleContext.o \
	WordList.o \
	AutoComplete.o \
	CallTip.o \
	Catalogue.o \
	CellBuffer.o \
	CharClassify.o \
	ContractionState.o \
	Decoration.o \
	Document.o \
	Editor.o \
	ExternalLexer.o \
	Indicator.o \
	KeyMap.o \
	LineMarker.o \
	PerLine.o \
	PositionCache.o \
	RESearch.o \
	RunStyles.o \
	ScintillaBase.o \
	Selection.o \
	Style.o \
	UniConversion.o \
	ViewStyle.o \
	XPM.o

$(COMPLIB): $(MARSHALLER) $(LEXOBJS) $(SRCOBJS)
	$(AR) rc $@ $^
	$(RANLIB) $@

deps.mak:
	$(CXX) -MM  $(CXXFLAGS) gtk/*.cxx lexers/*.cxx lexlib/*.cxx src/*.cxx >deps.mak

# Generate header dependencies with "make deps.mak"
include deps.mak
